/*
  This file is part of 'Trivial chess'.

  'Trivial chess' is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  'Trivial chess' is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with 'Trivial chess'.  If not, see <http://www.gnu.org/licenses/>.
*/

/* SVN FILE: $Id$ */
/**
 * @author         $Author$
 * @version        $Rev$
 * @lastrevision   $Date$
 * @filesource     $URL$
 */


//#define BOOST_TEST_MODULE Color
#include <boost/test/unit_test.hpp>
#include "../config.h"


BOOST_AUTO_TEST_SUITE( ColorTest )

BOOST_AUTO_TEST_CASE( testEqual ) {
	Color color = Color::WHITE();
	BOOST_CHECK_EQUAL(color, Color::WHITE());
	color = Color::BLACK();
	BOOST_CHECK_EQUAL(color, Color::BLACK());
	color = Color::NIL();
	BOOST_CHECK_EQUAL(color, Color::NIL());
}

BOOST_AUTO_TEST_CASE( testNotEqual ) {
	Color color = Color::WHITE();
    BOOST_CHECK_NE( color, Color::BLACK() );
    BOOST_CHECK_NE( color, Color::NIL() );
    color = Color::BLACK();
    BOOST_CHECK_NE( color, Color::WHITE() );
    BOOST_CHECK_NE( color, Color::NIL() );
    color = Color::NIL();
    BOOST_CHECK_NE( color, Color::WHITE() );
    BOOST_CHECK_NE( color, Color::BLACK() );
}

BOOST_AUTO_TEST_CASE( testIsWhite ) {
	Color color = Color::WHITE();
    BOOST_CHECK( color.isWhite() );
    color = Color::BLACK();
    BOOST_CHECK( !color.isWhite() );
    color = Color::NIL();
    BOOST_CHECK( !color.isWhite() );
}

BOOST_AUTO_TEST_CASE( testIsBlack ) {
	Color color = Color::WHITE();
    BOOST_CHECK( !color.isBlack() );
    color = Color::BLACK();
    BOOST_CHECK( color.isBlack() );
    color = Color::NIL();
    BOOST_CHECK( !color.isBlack() );
}

BOOST_AUTO_TEST_CASE( testIsNil ) {
	Color color = Color::WHITE();
    BOOST_CHECK( !color.isNil() );
    color = Color::BLACK();
    BOOST_CHECK( !color.isNil() );
    color = Color::NIL();
    BOOST_CHECK( color.isNil() );
}

BOOST_AUTO_TEST_CASE( testRival ) {
	Color color = Color::WHITE();
    BOOST_CHECK( color.rival().isBlack() );
    color = Color::BLACK();
    BOOST_CHECK( color.rival().isWhite() );
}

BOOST_AUTO_TEST_CASE( testSetRival ) {
	Color color = Color::WHITE();
	color.setRival();
    BOOST_CHECK( color.isBlack() );
    color = Color::BLACK();
    color.setRival();
    BOOST_CHECK( color.isWhite() );
}

BOOST_AUTO_TEST_CASE( testToInt ) {
	Color color = Color::WHITE();
    BOOST_CHECK_EQUAL(color.toInt(), 0 );
    color = Color::BLACK();
    BOOST_CHECK_EQUAL(color.toInt(), 1);
}

BOOST_AUTO_TEST_CASE( testFromInt ) {
	Color color;
	color.fromInt(0);
    BOOST_CHECK_EQUAL(color, Color::WHITE());
    color.fromInt(1);
    BOOST_CHECK_EQUAL(color, Color::BLACK());
}

BOOST_AUTO_TEST_CASE( testColor_Int ) {
	Color color = Color(0);
    BOOST_CHECK_EQUAL(color, Color::WHITE());
    color = Color(1);
    BOOST_CHECK_EQUAL(color, Color::BLACK());
}

BOOST_AUTO_TEST_CASE( testInc ) {
	Color color = Color::WHITE();
    BOOST_CHECK( (++color).isBlack() );
    BOOST_CHECK_EQUAL(++color, Color::END());
}

BOOST_AUTO_TEST_CASE( testDec ) {
	Color color = Color::BLACK();
    BOOST_CHECK( (--color).isWhite() );
    BOOST_CHECK_EQUAL(--color, Color::REND());
}

BOOST_AUTO_TEST_CASE( toStrTest ) {
	Color color = Color::BLACK();
    BOOST_CHECK_EQUAL(color.toStr(), "b");
    color = Color::WHITE();
    BOOST_CHECK_EQUAL(color.toStr(), "w");
    color = Color::NIL();
    BOOST_CHECK_EQUAL(color.toStr(), "-");
}

BOOST_AUTO_TEST_CASE( fromStrTest ) {
	Color color;
	color.fromStr("w");
    BOOST_CHECK( color.isWhite() );
    color.fromStr("b");
    BOOST_CHECK( color.isBlack() );
    color.fromStr("-");
    BOOST_CHECK( color.isNil() );
}

BOOST_AUTO_TEST_SUITE_END()
